package com.qyhl.module_practice.score.shop.detail;


import com.qyhl.webtv.commonlib.entity.civilized.PracticeShopListBean;

public class PracticeScoreShopDetailPresenter implements PracticeScoreShopDetailContract.PracticeScoreShopDetailPresenter {
    private PracticeScoreShopDetailActivity mView;
    private PracticeScoreShopDetailModel mModel;

    PracticeScoreShopDetailPresenter(PracticeScoreShopDetailActivity mView) {
        this.mView = mView;
        this.mModel = new PracticeScoreShopDetailModel(this);
    }

    @Override
    public void getDetail(String itemId) {
        mModel.getDetail(itemId);
    }

    @Override
    public void doExchange(String itemId, String volId, String phone) {
        mModel.doExchange(itemId, volId, phone);
    }

    @Override
    public void setDetail(PracticeShopListBean bean) {
        mView.setDetail(bean);
    }

    @Override
    public void setError(String msg) {
        mView.setError(msg);
    }

    @Override
    public void exchangeSuccess(String msg) {
        mView.exchangeSuccess(msg);
    }

    @Override
    public void exchangeError(int code) {
        switch (code) {
            case 301:
                mView.exchangeError("购买失败，该商品不存在！");
                break;
            case 302:
                mView.exchangeError("积分不足，成为志愿者赚积分！");
                break;
            case 303:
                mView.exchangeError("购买失败，积分不足！");
                break;
            case 304:
                mView.exchangeError("购买失败，库存不足！");
                break;
            case 310:
                mView.exchangeError("商品已经过了兑换时间！");
                break;
            case -1:
                mView.exchangeError("购买出错，请稍后再试！");
                break;
            default:
                mView.exchangeError("购买失败，请稍后再试！");
                break;
        }
    }
}
